package com.ruoyi.web.controller.system;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProjectStatistics;
import com.ruoyi.system.service.IProjectStatisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目统计Controller
 * 
 * @author ruoyi
 * @date 2022-04-20
 */
@Api(tags = "项目统计")
@RestController
@RequestMapping("/system/statistics")
public class ProjectStatisticsController extends BaseController
{
    @Autowired
    private IProjectStatisticsService projectStatisticsService;

    /**
     * 查询项目统计列表
     */
    @ApiOperation(value = "查询项目统计列表")
    @PreAuthorize("@ss.hasPermi('system:statistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectStatistics projectStatistics)
    {
        startPage();
        List<ProjectStatistics> list = projectStatisticsService.selectProjectStatisticsList(projectStatistics);
        return getDataTable(list);
    }

    /**
     * 导出项目统计列表
     */
    @ApiOperation(value = "导出Excel")
    @PreAuthorize("@ss.hasPermi('system:statistics:export')")
    @Log(title = "项目统计", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProjectStatistics projectStatistics)
    {
        List<ProjectStatistics> list = projectStatisticsService.selectProjectStatisticsList(projectStatistics);
        ExcelUtil<ProjectStatistics> util = new ExcelUtil<ProjectStatistics>(ProjectStatistics.class);
        return util.exportExcel(list, "项目统计数据");
    }

    /**
     * 获取项目统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(projectStatisticsService.selectProjectStatisticsById(id));
    }

    /**
     * 新增项目统计
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:add')")
    @Log(title = "项目统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectStatistics projectStatistics)
    {
        return toAjax(projectStatisticsService.insertProjectStatistics(projectStatistics));
    }

    /**
     * 修改项目统计
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:edit')")
    @Log(title = "项目统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectStatistics projectStatistics)
    {
        return toAjax(projectStatisticsService.updateProjectStatistics(projectStatistics));
    }

    /**
     * 删除项目统计
     */
    @PreAuthorize("@ss.hasPermi('system:statistics:remove')")
    @Log(title = "项目统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectStatisticsService.deleteProjectStatisticsByIds(ids));
    }
}
